import {
  BugOutlined,
  CloudServerOutlined,
  InsertRowAboveOutlined,
  OrderedListOutlined,
  TableOutlined,
} from "@ant-design/icons";
import React, { lazy } from "react";
import { Redirect } from "react-router-dom";
import { IRouteItem } from "src/constants/interfaces/IRouterItem";
import NotFound from "./exceptions/notFound";

/**
 * 异步加载工具
 * 带有webpack打包名
 */
const loader = (path: string) =>
  lazy(() => import(/* webpackChunkName: '[request]-[index]' */ `./${path}`));

export const routeItems: IRouteItem[] = [
  {
    path: "/",
    exact: true,
    hide: true,
    name: "首页",
    children: <Redirect to="/dataflow/add" />,
  },
  {
    path: "/dashboard",
    name: "Dashboard",
    icon: <CloudServerOutlined />,
    component: loader("dashboard"),
  },
  {
    path: "/tables",
    name: "表格",
    icon: <TableOutlined />,
    routes: [
      {
        name: "基础表格",
        path: "/tables/basic",
        icon: <InsertRowAboveOutlined />,
        component: loader("tables/basic"),
      },
    ],
  },
  {
    path: "/test",
    name: "模态框和抽屉",
    icon: <BugOutlined />,
    component: loader("test"),
  },
  {
    path: "/dataflow",
    name: "数据集成",
    icon: <TableOutlined />,
    routes: [
      {
        name: "集成监控", // 数据集成统计图表
        path: "/dataflow/dashboard",
        icon: <OrderedListOutlined />,
        component: loader("dataflow/list"),
      },
      {
        name: "任务管理", // 任务列表，管理任务：部署，启停等
        path: "/dataflow/tasks",
        icon: <OrderedListOutlined />,
        component: loader("dataflow/list"),
      },
      {
        name: "新建任务", // 新建和修改任务
        path: "/dataflow/add",
        icon: <OrderedListOutlined />,
        component: loader("dataflow/add"),
      },
      {
        name: "任务监控", // 查看单个任务运行时信息
        path: "/dataflow/monitor",
        icon: <OrderedListOutlined />,
        component: loader("dataflow/list"),
      },
      {
        name: "任务日志", // 查看单个任务日志详情
        path: "/dataflow/logs",
        icon: <OrderedListOutlined />,
        component: loader("dataflow/list"),
      },
      {
        name: "模板管理", // 任务模板列表管理
        path: "/dataflow/templates",
        icon: <OrderedListOutlined />,
        component: loader("dataflow/list"),
      },
      {
        name: "导入模板",
        path: "/dataflow/import",
        icon: <OrderedListOutlined />,
        component: loader("dataflow/list"),
      },
      {
        name: "集成配置", // 数据集成引擎地址等参数配置
        path: "/dataflow/settings",
        icon: <OrderedListOutlined />,
        component: loader("dataflow/list"),
      },
    ],
  },
  {
    hide: true,
    path: "/**",
    component: NotFound,
    name: "404页面未找到",
  },
];
